package com.demo.lab.utils;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class TimeUtils {
    public static String getTime() {
        Date date = new Date();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return (dateFormat.format(date)).toString();
    }

    public static String getTime2() {
        Date date = new Date();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        return (dateFormat.format(date)).toString();
    }

    public static String getTime3() {
        Date date = new Date();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
        return (dateFormat.format(date)).toString();
    }

    public static boolean timeComparison(String nowTime, String returnTime) {
        int flag = nowTime.compareTo(returnTime);
        //如果是大于0 则nowTime大于returnTime
        //返回正值是代表左侧日期大于参数日期，反之亦然
        if (flag < 0 || flag == 0) {
            //状态正常
            return true;
        } else {
            //逾期
            return false;
        }
    }

}
